package com.hzf.wxplatform.common.utils;

import com.hzf.common.util.ByteUtils;
import com.hzf.common.util.RedisUtil;
import org.omg.CORBA.INTERNAL;

import javax.servlet.http.HttpSession;

public class UcenterUserUtils {
    private final static String HZF_WX_CLIENT_SESSION_ID = "hzf-upms-client-session-id";

    public static boolean isLogin(int value) {
        if (value == 0) {
            return true;
        } else {
            return false;
        }

    }

    public static byte[] getUser(HttpSession session){
        Integer userID = (Integer) session.getAttribute(HZF_WX_CLIENT_SESSION_ID + "userid");
        System.out.println("用户ID"+userID);
        if (userID != null) {
            String key = "user" + userID.toString();
            byte[] b = RedisUtil.get(key.getBytes());
            if (b != null) {
                return  b;
            }
        }
        return null;
    }
    public static byte[] getOpen(HttpSession session){
        Integer userID = (Integer) session.getAttribute(HZF_WX_CLIENT_SESSION_ID + "userid");
        System.out.println(userID);
        if (userID != null) {
            String key = "user" + userID.toString();
            byte[] b = RedisUtil.get(key.getBytes());
            if (b != null) {
                return  b;
            }
        }
        return null;
    }
    public static byte[] getAddress(Integer id){
            String key = "addressKey" + id.toString();
            byte[] b = RedisUtil.get(key.getBytes());
            if (b != null) {
                return  b;
            }

        return null;
    }

}
